<template>
    <div>
      <div class="input">
       <input type="text" @keyup="xiangguan" placeholder="请输入歌曲名或者歌手名" v-model="ss">
      </div>
       <div v-if="ss" class="xianshi">
        <p>搜索“{{ss}}”</p>
       </div>
    <div class="reisuo" v-if="!ss">
        <p>热门搜索</p>
        <div class="biaoqian" >
            <ul>
                <li @click="dian(item.first)" res="wen" v-for="item in list" :key="item.index">{{item.first}}</li>
            </ul>
        </div>
    </div>
    <div class="shuju" v-show="ss">
      <ul>
          <li v-for="item in listgd" :key="item.index" @click="getgd(item.id)">
              <div class="left">
                  <span>&#xe7f6;</span>
              </div>
              <div class="right"><p >{{item.name}}</p></div>
          </li>
      </ul>
    </div>
    </div>
   
</template>

<script>
export default {
    data(){
        return {
            ss:'',
            list:[],
            listgd:[],
            dd:true
        }
    },
    created(){
     this.biaoqian()
    //  this.xiangguan()
    },
    methods:{
        biaoqian(){
            this.$axios.get("/search/hot")
            .then(res=>{
                this.list = res.data.result.hots
            })
        },
        xiangguan(){
            if(!this.dd) return
            this.$axios.get("/search?keywords="+this.ss)
             .then(res=>{
                //  console.log(res)
                 this.listgd = res.data.result.songs
             })
        },
        getgd(ids){
            this.$router.push({name:'yinyue',params:{id:ids}})
        },
        dian(id){
            this.ss = id
            this.xiangguan()
        }
    }

}
</script>

<style scoped>
.input{
    width:100%;
    padding:15px 30px;
    border-bottom:1px solid #ddd;
}
.input>input{
    width:100%;
    height:30px;
    padding:15px 30px;
    border:none;
    border-radius: 30px;
    background-color:#ddd;
    color:#999999;
    outline: none;
}
.xianshi{
    color:royalblue;
    width:100%;
    padding:15px 30px;
}
.reisuo{
    width:100%;
    padding:20px 15px;
}
.reisuo>p{
    font-size:12px;
    color:#888888;
    margin:10px 0;
}
.reisuo>.biaoqian>ul::after{
    content:"";
    display: block;
    clear:both;
}
.reisuo>.biaoqian>ul>li{
    padding:6px 15px;
    color:#888888;
    border:1px solid #ddd;
    text-align: center;
    float:left;
    border-radius: 30px;
    margin:5px 10px;
}
.shuju{
    width:100%;
}
.shuju>ul>li{
  width:100%;
  padding:12px 10px;
  display:flex;
  justify-content: space-between;
  /* height:40px; */
}
.shuju>ul>li>.left{
    width:15%;
    text-align: center;
    line-height: 40px;
}
.shuju>ul>li>.left>span{
    font-family: "wy";
    font-size: 20px;
}
.shuju>ul>li>.right{
    width:85%;
    padding:10px 15px;
    color:#888888;
    font-size: 15px;
    border-bottom:1px solid #ddd;
}
</style>